const filter = {
  formatDate(value) {
    const date = new Date(value)
    const y = date.getFullYear()
    let MM = date.getMonth() + 1
    MM = MM < 10 ? '0' + MM : MM
    let d = date.getDate()
    d = d < 10 ? '0' + d : d
    let h = date.getHours()
    h = h < 10 ? '0' + h : h
    let m = date.getMinutes()
    m = m < 10 ? '0' + m : m
    let s = date.getSeconds()
    s = s < 10 ? '0' + s : s
    return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
  },

  roleData(arr1, arr2) {
    return arr1.filter(ele => arr2.filter(x => x === ele.id).length > 0)
  }
}

export default function registerFilters(Vue) {
  Object.keys(filter).forEach(key => {
    Vue.filter(key, filter[key])
  })
  console.log('全局过滤器加载完成')
}
